
    $(function () {
        var flagPas = false;
        var flagPass = false;
        var flagAccount = false;
        var passWordForm, passWordForms, accountForm;

        $("#registernumber").change(function () {
            accountForm = $("#registernumber").val();
            if (accountForm == "") {
                $("#registernumber").removeClass("form-control is-valid")
                $("#registernumber").addClass("form-control is-invalid");
                flagAccount = false;
            } else {
                $("#registernumber").removeClass("form-control is-invalid")
                $("#registernumber").addClass("form-control is-valid");
                flagAccount = true;
            }
        })
        $("#registerpassword").change(function () {
            passWordForm = $("#registerpassword").val();
            if (passWordForm == "") {
                $("#registerpassword").removeClass("form-control is-valid")
                $("#registerpassword").addClass("form-control is-invalid");
                flagPas = false;
            } else {
                $("#registerpassword").removeClass("form-control is-invalid")
                $("#registerpassword").addClass("form-control is-valid");
                flagPas = true;
            }
        })
        $("#registerrepassword").change(function () {
            passWordForm = $("#registerpassword").val();
            passWordForms = $("#registerrepassword").val();
            if ((passWordForm != passWordForms)) {
                $("#registerrepassword").removeClass("form-control is-valid")
                $("#registerrepassword").addClass("form-control is-invalid");
                flagPass = false;
            } else {
                $("#registerrepassword").removeClass("form-control is-invalid")
                $("#registerrepassword").addClass("form-control is-valid");
                flagPass = true;
            }
        })
        $("#register").click(function () {
            if (flagPas && flagPass && flagAccount) {
                return true;
            } else {
                if (!flagPas) {
                    $("#registerpassword").addClass("form-control is-invalid");
                }
                if (!flagPass) {
                    $("#registerrepassword").addClass("form-control is-invalid");
                }
                if (!flagAccount) {
                    $("#usernameInfo").html("未输入管理员账号或已存在");
                    $("#usernameInfo").css("font-size", "80%");
                    $("#usernameInfo").css("color", "#dc3545");
                    $("#registernumber").addClass("form-control is-invalid");
                }
                return false;
            }
        })
    })


$(function () {
    //1.为输入框绑定事件,失去焦点获得输入框内容
    $("#registernumber").blur(function () {
        var usernameInput = $(this).val();
        //2.去服务器端校验用户名是否存在 ---ajax
        $.ajax({
            url: "findAddadminnum",
            type: "POST",
            dataType: "json",
            data: {"username": usernameInput},
            success: function (data) {
                var isExist = data.isExist;
                //根据返回的isExist动态显示信息
                var usernameInfo = "";
                $("#usernameInfo").css("font-size", "80%");
                if (isExist || ($("#registernumber").val() == "")) {
                    //用户存在
                    usernameInfo = "未输入管理员账号或已存在"
                    $("#usernameInfo").css("color", "#dc3545");
                    $("#registernumber").addClass("is-invalid");

                } else {
                    usernameInfo = "该管理员账号可以使用"
                    $("#usernameInfo").css("color", "green");
                    $("#registernumber").addClass("is-valid");
                }
                $("#usernameInfo").html(usernameInfo);
            }
        });
    });
})